package com.bush.mall.product.controller;

import org.springframework.web.bind.annotation.*;
import com.bush.mall.common.entity.Result;;
import com.bush.mall.product.entity.SpuInfoEntity;
import com.bush.mall.product.service.SpuInfoService;
import javax.annotation.Resource;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * spu信息
 * @author RUN
 * @date 2022-11-28
 */
@RestController
@RequestMapping("spuinfo")
@Api(tags = "spu信息管理" )
public class SpuInfoController {

    @Resource(name= SpuInfoService.BEAN_ID)
    private SpuInfoService spuInfoService;

    /**
     * 分页查询spu信息列表
     * @author RUN
     * @date 2022-11-28
     */
    @ApiOperation(value = "分页查询spu信息列表")
    @GetMapping("queryForPage")
    public Result queryForPage(Integer current,Integer size){
        return spuInfoService.queryForPage(current,size);
    }

    /**
     * 保存spu信息表单
     * @author RUN
     * @date 2022-11-28
     */
    @ApiOperation(value = "保存spu信息表单")
    @PostMapping("saveSpuInfo")
    public Result saveSpuInfo(@RequestBody SpuInfoEntity spuInfo){
        return spuInfoService.saveSpuInfo(spuInfo);
    }

    /**
     * 修改spu信息表单
     * @author RUN
     * @date 2022-11-28
     */
    @ApiOperation(value = "修改spu信息表单")
    @PutMapping("updateSpuInfo")
    public Result updateSpuInfo(@RequestBody SpuInfoEntity spuInfo){
        return spuInfoService.updateSpuInfo(spuInfo);
    }

    /**
     * 通过指定id删除spu信息
     * @author RUN
     * @date 2022-11-28
     */
    @ApiOperation(value = "通过指定id删除spu信息")
    @DeleteMapping("deleteSpuInfo")
    public Result deleteSpuInfo(Long id){
        return spuInfoService.deleteSpuInfo(id);
    }

}
